<?php 
	class Errors extends Model_Abstract{
		
		public function getErrors($page)
		{
			$pageSize = is_null(Q::ini('appini/items_per_page')) ?  10 : Q::ini('appini/items_per_page');
			
			$limitFrom = ($page-1)*$pageSize;
			$sql = "SELECT * FROM `errors` ORDER BY `created` DESC LIMIT ".$limitFrom." , 10";
			try	
			{
				return $this->_connection->query($sql);
			}
			catch (Exception $e)
			{
				Qlog::log(__CLASS__.' '.__METHOD__.' --- '.$e->getMessage(), Qlog::ERR);
				throw new Model_Exception($e->getMessage, $e->getCode());
			}
		}	
		
		public function getErrorsNum(){
			$sql = "SELECT count(*) AS num FROM `errors` ";
			try 
			{
				$result = $this->_connection->query($sql);
				return $result[0]['num'];
			}
			catch (Exception $e)
			{
				Qlog::log(__CLASS__.' '.__METHOD__.' --- '.$e->getMessage(), Qlog::ERR);
				throw new Model_Exception($e->getMessage, $e->getCode());
			}
		}
	}

?>